package com.xbs.service.selfdriving;

import java.util.ArrayList;
import java.util.List;

import com.xbs.dao.selfdriving.SelfDrivingDao;
import com.xbs.entity.CarModelEntity;
import com.xbs.entity.CityEntity;
import com.xbs.entity.PagesEntity;
import com.xbs.entity.TimeCombo;

public class SelfDrivingService {
	//创建一个SelfDrivingDao对象
	private SelfDrivingDao sd;
	
	public SelfDrivingService() {
		sd = new SelfDrivingDao();
	}
	/**
	 * 1.查找车型表中的所有车型
	 * @return
	 */
//	public List<CarModelEntity> selCarModel(String type,Double price,Double price2,String pin){
//		List<CarModelEntity> carmodel = new ArrayList<CarModelEntity>();
//		carmodel = sd.selCarModel(type,price,price2,pin);
//		return carmodel;
//	}
	
	/**
	 * 进行分页
	 * @param type
	 * @param price
	 * @param price2
	 * @param pin
	 * @param currpage
	 * @param pagesize
	 * @return
	 */
	public PagesEntity<CarModelEntity> selCarModel(String type,Double price,Double price2,String pin,int currpage,int pagesize){
		//计算起始记录数
		int curr = (currpage-1)*pagesize;
		//获取分页数据
		List<CarModelEntity> carmodel = new ArrayList<CarModelEntity>();
		carmodel = sd.selCarModel(type,price,price2,pin,curr,pagesize);
		//获取总记录数
		int total = sd.selCarModelTotal(type, price, price2, pin);
		return new PagesEntity<CarModelEntity>(currpage,pagesize,total,carmodel);
	}
	
	/**
	 * 获取检索结果的总记录数
	 * @param type
	 * @param price
	 * @param price2
	 * @param pin
	 * @return
	 */
	public int selCarModelTotal(String type,Double price,Double price2,String pin){
		return sd.selCarModelTotal(type, price, price2, pin);
	}
	
	/**
	 * 2.查找拥有门店的城市
	 * @return
	 */
	public List<CityEntity> selCity(){
		List<CityEntity> city = sd.selCity();
		return city;
	}
	
	/**
	 * 3.查找每种套餐的折扣
	 */
	public Double getTimeCombo(String time){
		return sd.getTimeCombo(time);
	}
}
